/* your js go here */
$(function () {
    $("#pic").click(function () {
        $("#picFile").click()
    })

    $('#picFile').change(function () {
        var formData = new FormData();
        formData.append("iconFile", document.getElementById("picFile").files[0]);
        $.ajax({
            url: "/user/updatePic",
            processData: false,
            contentType: false,
            data: formData,
            type: "post",
            async: true,
            success: function (res) {
                window.location="/html/user_look.jsp";
                if (res.status == 200) {
                    layer.msg('上传成功');
                    $("#picFile").val("");
                    $("#pic").attr("src", res.picUrl);
                    $("#loginUserPic").attr("src", res.picUrl);
                } else {
                    layer.msg(res.message);
                }
            },
            error: function (data) {
                layer.msg('服务器忙');
            }
        });
    });


    $("#avatar").click(function () {
        console.log("你点击了头像");
        window.location.href = '/user/showUserMessage'
    });

    //file表单选中文件时,让file表单的val展示到showname这个展示框
    $('#myFile').change(function () {
        $('#showname').val($(this).val())
    });

    //用户列表，查看详情，通过class名字userDetail来找
    // $(".userDetail").click(function () {
    //     console.log("你点击了用户详情");
    //     $(this).style.name
    //     window.location.href = '../user/userMessage'
    // });

    //发布会议跳转链接
    $("#addMeet").click(function () {
        window.location.href = '../html/meeting_add.html'
    });

    //添加文章跳转链接
    $("#addArt").click(function () {
        window.location.href = '../html/article_add.html'
    });


    $(".myList>ul>li").on("click", function () {
        if ($(this).find("div").attr('class') == 'list-group myGroup isHidden') {
            $(this).find("div").removeClass("isHidden")
        } else {
            $(this).find("div").addClass("isHidden")
        }


    })

    $(".table").find("input[type='checkbox']").on("click", function () {
        if ($(this).prop("checked")) {
            layer.msg("关注成功")
        } else {
            layer.msg("取关成功")
        }
    })


});

